package router

import (
	"gin-test/controllers"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Router() *gin.Engine {
	r := gin.Default()

	/*r.GET("/hello", func(ctx *gin.Context) {
		ctx.String(http.StatusOK, "Hello 2222")
	})*/

	user := r.Group("/user")
	{
		/*user.POST("/list", func(ctx *gin.Context) {
			ctx.String(http.StatusOK, "user list")
		})*/
		user.POST("/add", func(ctx *gin.Context) {
			ctx.String(http.StatusOK, "user add")
		})
		//user.GET("/info", controllers.GetUserInfo) // 这个访问不到了
		user.GET("/info", controllers.UserController{}.GetUserInfo)
		user.GET("/list", controllers.UserController{}.GetList)
	}
	order := r.Group("/order")
	{
		order.GET("/list", controllers.OrderController{}.GetList)
		order.GET("/info/:id", controllers.OrderController{}.GetInfo)
	}

	//r.Run(":9999")
	return r
}
